import axios from "axios";
//axios的封装
import { showNotify } from "vant";
let instance = axios.create({
  baseURL: "/api",
  //设置超时时间
  timeout: 5000,
});
//请求拦截器
instance.interceptors.request.use((config) => {
  //携带请求头
  if(localStorage.getItem("token")){
      config.headers.token = localStorage.getItem("token");
  }
  return config;
});
//响应拦截器
//顶部消息提示请求结果
//vant组件库
instance.interceptors.response.use((res) => {
  showNotify({ type: 'success',message: `${res.data.message}`,duration:1000 });
  return res;
});

export default instance;


